import allure

from page_element.el_commodity import product
from page_object.roncoo_login import RoncooLogin
from page_element.el_A3mall import *
import logging
from utils.timer import sleep



class Add_product_grounding(RoncooLogin):
    """添加菜单"""

    def page_product_grounding_login(self, info1,info2,value1,value2,info3):
        # 前置条件：已登录
        self.roncoo_login()
        with allure.step(f"点击支付管理"):
            sleep(2)
            self.click(product.pay_manage)
        with allure.step(f"点击支付产品信息"):
            sleep(2)
            self.click(product.pay_product_msg)
        with allure.step(f"点击添加支付产品"):
            self.click(product.add_pay_product)
            sleep(3)
        with allure.step(f"输入产品编码"):
            self.send_keys(product.product_number,info1)
            sleep(2)
        with allure.step(f"输入产品名称"):
            self.send_keys(product.product_name,info2)
            sleep(4)
        with allure.step(f"点击提交"):
            self.click(product.submit_btn)
            sleep(2)
        with allure.step(f"设置支付方式"):
            self.click(product.set_pay)
            sleep(2)
        with allure.step(f"点击设置支付方式"):
            self.click(product.set_pay_btn)
            sleep(2)
        with allure.step(f"选择支付方式"):
            self.select_by_value(product.select_pay_way,value1)
            sleep(2)
        with allure.step(f"选择支付类型"):
            self.select_by_value(product.select_pay_type,value2)
            sleep(2)
        with allure.step(f"输入支付费率"):
            self.send_keys(product.pay_money,info3)
            sleep(5)
        with allure.step(f"点击提交2"):
            self.click(product.submit2_btn)
            sleep(4)
        with allure.step(f"点击上架"):
            self.click(product.grounding)
            sleep(4)
        with allure.step(f"断言支付产品名称"):
            dy = self.text(product.dy)
            assert '支付产品名称' == dy
